/**
 * 
 */

/**
 * @author xzy
 *
 */
import java.util.Arrays;


public class Code {
  public  String firstUpper(String str) {
    if (str == null||str.length()==0) {
    }else {
      char c = str.charAt(0);
      if (c >= 'a' && c <= 'z') {
        str= Character.toUpperCase(c) + str.substring(1);
      }
    }
    return str;
  }
  public String sort(String str) {
    String result;
    if (str == null || str.length() == 0) {
      result = "";
    } else {
      char[] allChars = str.toCharArray();
      Arrays.sort(allChars);
      StringBuilder sBuilder = new StringBuilder();
      char temp = allChars[0];
      int count = 0;
      for (int i = 0; i < allChars.length; i++) {
        if (temp == allChars[i]) {
          count++;
        } else {
          sBuilder.append(temp).append(count);
          count = 1;
          temp = allChars[i];
        }
      }
      sBuilder.append(temp).append(count);
      result = sBuilder.toString();
    }
    return result;
  }

  public boolean checkPhone(String phone) {
    boolean isRight = false;
    if (phone.startsWith("13") || phone.startsWith("15") || phone.startsWith("17") || phone.startsWith("18")) {
      if (phone.length() == 11) {
        char oneChar;
        int i;
        for (i = 0; i < phone.length(); i++) {
          oneChar = phone.charAt(i);
          if (!Character.isDigit(oneChar)) {
            break;
          }
        }
        if(i==phone.length()) {
          isRight = true;
        }
      }
    }
    return isRight;
  }

  public boolean checkPassword(String pw1, String pw2) {
    boolean isRight = true;
    if (!pw1.equals(pw2) || pw1.length() < 6) {
      isRight = false;
    } else {
      int nUpper = 0, nLower = 0, nDig = 0;
      char ch;
      for (int i = 0; i < pw1.length(); i++) {
        ch = pw1.charAt(i);
        if (Character.isUpperCase(ch)) {
          nUpper++;
        } else if (Character.isLowerCase(ch)) {
          nLower++;
        } else if (Character.isDigit(ch)) {
          nDig++;
        }
      }
      if (nUpper * nLower * nDig == 0) {
        isRight = false;
      }
    }
    return isRight;
  }
}
